package net;

import java.io.IOException;
import java.net.InetAddress;

import messages.Message;
import exceptions.CommunicationException;

/**
 * A ClientCommunicator is responsible to provide the communication mechanisms
 * between the server and one client.
 * 
 * There will be derived classes that handle the specific details of 
 * each communication-method (Sockets, RMI, etc).
 * 
 * @see User
 */
public interface ClientCommunicator {
	
	
	/**
	 * Receives a message from the client application.
	 * 
	 * @return The message read.
	 * @throws CommunicationException
	 */
	public Message receive();
	
	
	/**
	 * Sends a message to the client application.
	 * 
	 * @param message The message to be sent.
	 * @throws CommunicationException
	 */
	public void send(Message message) throws IOException;
	
	
	/**
	 * This method is called whenever the client is about to go
	 * offline. Book-keeping should go here.
	 */
	public void close();
	
	
	/**
	 * Returns the client's address
	 * 
	 * @return The client's address
	 */
	public InetAddress getAddress();
}
